package hcd.mynote;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;

public class HomeActivity extends AppCompatActivity {

    public static final int HOME_FRAGMENT = 1000;
    public static final int EDIT_FRAGMENT = 1001;
    public static final int USER_FRAGMENT = 1002;
    private int currentFragment = HOME_FRAGMENT;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);


//        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
//            @Override
//            public boolean onMenuItemClick(MenuItem item) {
//
//                return false;
//            }
//        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_home, menu);
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        switch (currentFragment){
            case HOME_FRAGMENT:
                menu.findItem(R.id.action_sync).setVisible(true);
                menu.findItem(R.id.action_save).setVisible(false);
                break;
            case EDIT_FRAGMENT:
                menu.findItem(R.id.action_sync).setVisible(false);
                menu.findItem(R.id.action_save).setVisible(true);
                break;
            default:
                menu.findItem(R.id.action_sync).setVisible(false);
                menu.findItem(R.id.action_save).setVisible(false);
                break;
        }
        return super.onPrepareOptionsMenu(menu);
    }

//    @Override
//    public boolean onOptionsItemSelected(MenuItem item) {
//        switch (currentFragment){
//            case EDIT_FRAGMENT:
//
//                break;
//            default:
//                break;
//        }
//        return super.onOptionsItemSelected(item);
//    }

    public int getCurrentFragment() {
        return currentFragment;
    }

    public void setCurrentFragment(int currentFragment) {
        this.currentFragment = currentFragment;
    }

}
